<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:insert="~{common :: commomcss}"></head>
  <body>
  <!-- navbar-->
  <div th:replace="~{common :: commonheader}"></div>
  <div class="d-flex align-items-stretch">
    <div id="sidebar" class="sidebar py-3">
      <ul th:insert="~{common :: siderul}"></ul>
    </div>
    <div class="page-holder w-100 d-flex flex-wrap">
      <div class="container-fluid px-xl-5">
        <section class="py-5">
          <div class="row">
            <!-- Form Elements -->
            <div class="col-lg-12 mb-5">
              <div class="card">
                <div class="card-header">
                  <h3 class="h6 text-uppercase mb-0"></h3>
                </div>
                <div class="card-body">
                  <section class="py-5">
                    <div class="row text-dark">


                      <div class="col-lg-4 mb-4 mb-lg-0" th:each="publishWork : ${publishWorkVOList}">

                        <div class="card rounded credit-card bg-hover-gradient-violet">
                          <div class="content d-flex flex-column justify-content-between p-4">
                            <div class="d-flex justify-content-between align-items-end pt-3">
                              <div class="text-uppercase">
                                <div class="font-weight-bold d-block">发布时间<td th:text="${publishWork.getPublish().getPublishtime()}"></td></div>
                                <small class="text-gray">截至日期<td th:text="${publishWork.getPublish().getDeadline()}"></td></small>
                              </div>
                              <h4 class="mb-0">第<td th:text="${publishWork.getPublish().getSeq()}"></td>次</h4>
                            </div>
                            <div class="line"></div>
                            <div class="text-uppercase">
                              <a th:href="@{/student/showPublish(publishid=${publishWork.getPublish().getId()})}" target="_blank"><button type="button" class="btn btn-outline-info">查看作业内容</button></a>
                              <a th:href="@{/pageoffice/readWord(workid=${publishWork.getWorkid()})}" target="_blank"><button type="button" class="btn btn-outline-info">查看已提交</button></a>
                              <a><span class = "score" style="float: right" th:title="${publishWork.getWorkid()} ">教师未批改</span></a>
                            </div>
                            <div class="line"></div>
                            <div class="text-uppercase">
                              <form method="post" th:action="@{/student/submit}" enctype="multipart/form-data">
                                <!--隐藏的组件 保存workid-->
                                <input name="workid" th:value="${publishWork.getWorkid()}" style="visibility: hidden">
                                <!--隐藏的组件 保存publishid-->
                                <input name="publishid" th:value="${publishWork.getPublish().getId()}" style="visibility: hidden">
                                <!--上传作业附件-->
                                <div class="form-group row">
                                  <div class="col-md-8">
                                    <div class="custom-file">
                                      <input type="file" class="custom-file-input" name="file">
                                      <label class="custom-file-label">请选择文件</label>
                                    </div>
                                  </div>
                                  <div class="col-md-2">
                                    <input type="submit" value="提交" class="btn btn-outline-info">
                                  </div>
                                </div>
                              </form>
                            </div>
                          </div>
                        </div>
                      </div>

                    </div>
                  </section>
                  </form>
                </div>
              </div>
            </div>
          </div>
        </section>
      </div>
    </div>
  </div>
    <!-- JavaScript files-->
    <div th:insert="~{common :: commomjs}"></div>
  </body>

  <!--上传文件所需JS-->
  <script type="text/javascript" th:src="@{/assert/dist/bs-custom-file-input.js}"></script>
  <!--文件上传-->
  <script type="text/javascript">
    document.addEventListener('DOMContentLoaded', function() {
      bsCustomFileInput.init()
      var btn = document.getElementById('btnResetForm')
      var form = document.querySelector('form')
      btn.addEventListener('click', function () {
        form.reset()
      })
    });

   /*获取作业分数*/
    $(function () {
        // 作业得分数组
      var ss = $(".score");
      for (let index = 0; index < ss.length; index++) {
        var workid = ss[index].title;
        $.ajax({
          url: '/student/queryWorkScore/' + workid,
          type: 'get',
          success:function (score) {
            if(null != score && "" !== score && score !== "0") {
              ss[index].innerHTML = "得分：" + score;
            }
          }
          });
      }
    });
  </script>

</html>